<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class prosedur_model extends CI_Model {
    
	function __construct(){
        parent::__construct();
    }
	
	function OptionNamaKKKS($d=""){
		$value = isset($d['value'])?$d['value']:'';
		$out = '';
		
		$this->db->flush_cache();
		$this->db->from('R_KPS');
		$this->db->order_by('NAMA_KPS');
		$this->db->where('ID_KPS <=', '900');
		//$this->db->where('status', 'A');
		
		#Kimochi - otoritas
		/* if($this->session->userdata('kd_fakultas')!=''){
			$this->db->where('kd_fakultas', $this->session->userdata('kd_fakultas'));
		}else{ */
			$out = '<option value="">-- Pilih --</option>';
		//}
		#End Kimochi
		
		$res = $this->db->get();
		
		foreach($res->result() as $r){
			if(trim($r->ID_KPS) == trim($value)){
				$out .= '<option value="'.$r->ID_KPS.'" selected="selected">'.$r->NAMA_KPS.'</option>';
			}else{
				$out .= '<option value="'.$r->ID_KPS.'">'.$r->NAMA_KPS.'</option>';
			}
		}
		
		return $out;
	}
	function OptionWLevel($d=""){
		$value = isset($d['value'])?$d['value']:'';
		$out = '';
		
		$this->db->flush_cache();
		$this->db->from('R_WILAYAH_LEVEL');
		$this->db->order_by('LEVEL_ID');
		//$this->db->where('ID_KPS <=', '900');
		//$this->db->where('status', 'A');
		
		#Kimochi - otoritas
		/* if($this->session->userdata('kd_fakultas')!=''){
			$this->db->where('kd_fakultas', $this->session->userdata('kd_fakultas'));
		}else{ */
			$out = '<option value="">-- Pilih --</option>';
		//}
		#End Kimochi
		
		$res = $this->db->get();
		
		foreach($res->result() as $r){
			if(trim($r->LEVEL_ID) == trim($value)){
				$out .= '<option value="'.$r->LEVEL_ID.'" selected="selected">'.$r->NM_LEVEL.'</option>';
			}else{
				$out .= '<option value="'.$r->LEVEL_ID.'">'.$r->NM_LEVEL.'</option>';
			}
		}
		
		return $out;
	}
	function OptionNamaBulan($d=""){
		$value = isset($d['value'])?$d['value']:'';
		//echo $value;
		//echo ((int)date('m'));
		$out = '';
		
		
			$out = '<option value="">-- Pilih --</option>';
		
		
		$res = array(1=>'Januari',2=>'Februari',3=>'Maret',4=>'April',
					 5=>'Mei',6=>'Juni',7=>'Juli',8=>'Agustus',9=>'September',
					 10=>'Oktober',11=>'Nopember',12=>'Desember'
		);
		
		foreach($res as $key=>$val){
			if($key == $value){
				$out .= '<option value="'.$key.'" selected="selected">'.$val.'</option>';
			}else{
				$out .= '<option value="'.$key.'">'.$val.'</option>';
			}
		}
		
		return $out;
	}
	
	function OptionTahunRealisasi($d=""){
		$value = isset($d['value'])?$d['value']:'';
		
		$this->db->flush_cache();
		$this->db->Select('TAHUN');
		$this->db->from('LQ_LEGAL_TASK');
		$this->db->where('STATUS_PROSES','4');
		$this->db->group_by('TAHUN');
		$this->db->order_by('TAHUN','desc');
		
		$res = $this->db->get();
		
		$out = '';
		
		foreach($res->result() as $r){
			$out .= '<option value="'.$r->TAHUN.'">'.$r->TAHUN.'</option>';
		}
		
		return $out;
	}
	function OptionJenisOperator($d=""){
		$value = isset($d['value'])?$d['value']:'';
		$out = '';
		
		$this->db->flush_cache();
		$this->db->from('TS_MASTERS');
		//$this->db->order_by('LEVEL_ID');
		$this->db->where('TGROUP <=', 'JM');
		//$this->db->where('status', 'A');
		
		#Kimochi - otoritas
		/* if($this->session->userdata('kd_fakultas')!=''){
			$this->db->where('kd_fakultas', $this->session->userdata('kd_fakultas'));
		}else{ */
			$out = '<option value="">-- Pilih --</option>';
		//}
		#End Kimochi
		
		$res = $this->db->get();
		
		foreach($res->result() as $r){
			if(trim($r->CODE) == trim($value)){
				$out .= '<option value="'.$r->CODE.'" selected="selected">'.$r->CODE.'</option>';
			}else{
				$out .= '<option value="'.$r->CODE.'">'.$r->CODE.'</option>';
			}
		}
		
		return $out;
	}
	
	// selesai
}
?>